In the Delphi approach to Object Oriented Programming, everything revolves around the concept of 'Classes'. A class can be seen as a pointer to an object, or a pointer to a record.
The prototype declaration of a class is as follows :
TObj = Class [(ParentClassType)] [Constructor ConstructorName;] [Destructor DestructorName;] Field1 : Type1; ... Fieldn : Typen; Method1; Method2; [private PrField1 : PrType1; ... PrFieldn : PrTypen; PrMethod1; ... PrMethodn;] [public PuField1 : PuType1; .. Pufield1 : PuTypen; PuMethod1; ... PuMethodn;] end;You can repeat as many private and public blocks as you want. Methods are normal function or procedure declarations.
As you can see, the declaration of a class is almost identical to the declaration of an object. The real difference between objects and classes is in the way they are created;
Classes must be created using their constructor. Remember that A class is a pointer to an object, so when you declare a variable of some class, the compiler just allocates a pointer, not the entire object. The constructor of a class returns a pointer to an initialized instance of the object.
So, to initialize an instance of some class, you do the following :
ClassVar:=ClassType.ConstructorName;
Remark : Free Pascal doesn't support the concept of properties yet.